<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/23
 * Time: 22:07
 */

namespace App;


use Illuminate\Database\Eloquent\Model;

class Auth extends Model
{
    // 普通用户
    const NORMAL_USER = 0;
    // 角色用户
    const ROLE_USER = 1;
    // 表名称
    protected $table = 'auth';
    // 开启自动时间戳
    public $timestamps = true;
    // 日期都存储为时间戳
    protected $dateFormat = 'U';

    protected $appends = [];

    static protected $typeArray = [
        self::NORMAL_USER => '普通用户',
        self::ROLE_USER => '角色用户'
    ];

    // 追加status_text字段,status的文本类型
    public function getTypeTextAttribute()
    {
        return self::$typeArray[$this->attributes['type']];
    }

}